﻿package Naruto {	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
//	import flash.events.TimerEvent;
	import flash.ui.Keyboard;
//	import flash.utils.Timer;
	
//	import flash.display.MovieClip;
//	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.display.Stage;
//	import flash.text.TextFormat;
//	import flash.text.TextField;
	
//	import fl.transitions.*;
// 	import fl.transitions.easing.*;
	
//	import Naruto.Bloods.*;
	import Naruto.*;

	public class MissonResult {
		private var _stage:Stage;
		private var _levelNum:int;
		private var _gameResult:Boolean = true;
		private var _loadPic:LoadPic;
		private var _func:Function;
		
		public function MissonResult(stage:Stage, levelNum:int, gameResult:Boolean, func:Function){
			this._stage = stage;
			this._levelNum = levelNum;
			//trace(this._levelNum);
			this._gameResult = gameResult;
			this._func = func;
			
			if(this._gameResult == true){
				trace("Mission Success!");
				this._loadPic = new LoadPic(this._stage,500);
			}else if(this._gameResult == false){
				trace("Mission Faild");
				this._loadPic = new LoadPic(this._stage,501);
			}
			this._stage.addEventListener(MouseEvent.MOUSE_DOWN, clickButton);
		} 
		
		private function clickButton(event:MouseEvent){
			var result = this._loadPic.checkButtonName(event.target.name);
			//trace(result);
			switch(result){
				case "playAgain":{
									this._stage.removeEventListener(MouseEvent.MOUSE_DOWN, clickButton);
									this._func(-4);break;}	//-4：游戏失败
				case "Menu":{
								this._stage.removeEventListener(MouseEvent.MOUSE_DOWN, clickButton);
								this._func(-1);break;}
				default:trace("No name");break;
			}
		}
	}
}